﻿@model ECatalog.Models.Models.ModelView
@{
    Layout = null;
}

@foreach (var shop in Model.ShopModelSizes)
{
    <div class="modal fade" id="sizeModal-@shop.Shop.ShopId" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">Размеры в @shop.Shop.Name</h4>
                </div>
                <div class="modal-body">
                    @{
    var sizesShopid = "sizes-" + @shop.Shop.ShopId;
                    }
                    @using (Ajax.BeginForm("Add", "SizeModel", new AjaxOptions { UpdateTargetId = sizesShopid, HttpMethod = "POST", InsertionMode = InsertionMode.InsertAfter }))
                    {
                        @Html.HiddenFor(m => m.ModelId)
                        @Html.HiddenFor(m => m.OrganizationId)
                        <input type="hidden" name="ShopId" value="@shop.Shop.ShopId"/>
                        <div class="row col-lg-12">
                            <div class="col-lg-5">
                                @Html.TextBox("Value", "", new { @class = "form-control" })
                            </div>
                            <div class="col-lg-2">
                                <input type="submit" class="btn btn-primary" value="Добавить" />
                            </div>
                        </div>
                        <div class="row col-lg-12" id="sizes-@shop.Shop.ShopId"></div>
                    }
                    <div class="row col-lg-12">
                        @if (Model != null && shop.ModelSizeDtos.Any())
                        {
                            foreach (var size in shop.ModelSizeDtos)
                            {
                            <div class="row modelsize-item">
                                <div class='col-lg-5'><span>@size.Value</span></div>
                                <div class='col-lg-1 remove-modelsize' id='@size.ModelSizeId'><a href='#'>удалить</a></div>
                            </div>
                            }
                        }
                    </div>
                </div>
                <div class="modal-footer">
                    @if (@Model != null)
                    {
                        using (Html.BeginForm("EditModel", "Model", new { modelId = @Model.ModelId }))
                        {
                        <button type="submit" class="btn btn-default">Закрыть</button>
                        }
                    }
                </div>
            </div>
        </div>
    </div>
}